package com.wuxia.mvc.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class SystemController {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@RequestMapping(path = "/", method = { RequestMethod.GET })
	public String toLoginPage() {
		return "login";
	}

	@RequestMapping(path = "/login", method = { RequestMethod.POST })
	public String login() {
		System.out.println("hello");
		String sql = "select id,user_name,hukou_area,age,address from user_info";
		List<UserInfo> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<UserInfo>());
		return "list";
	}

}
